package com.lagou.edu.context;

/**
 * @Author zhaozuowen
 * @Description
 * @Date 2020-01-12 11:34
 **/

public class AnnotationTypeFilters implements TypeFilter {

    private String annotationType;

    private final boolean considerMetaAnnotations;

    public AnnotationTypeFilters(String annotationType) {
        this(annotationType,true);
    }
    public AnnotationTypeFilters(String annotationType,boolean considerMetaAnnotations) {
        this.annotationType = annotationType;
        this.considerMetaAnnotations=considerMetaAnnotations;
    }

    @Override
    public boolean ifMatch(MetadataReader metadataReader) {
        if(metadataReader.hasAnnotation(annotationType)||(considerMetaAnnotations&&metadataReader.hasMetaAnnotation(annotationType))){
            return true;
        }
        return false;
    }
}
